package com.deng.activity.service.impl;

import com.deng.activity.service.ActivityService;
import com.deng.activity.util.ActivityUtil;
import com.deng.activity.vo.ActivityDateVO;
import com.deng.activity.vo.ActivityDayVo;
import org.springframework.stereotype.Service;

import java.util.Calendar;

/**
 * 活动服务相关实现
 */
@Service
public class ActivityServiceImpl implements ActivityService {

    @Override
    public ActivityDateVO getActivityDate() {
        // 今天
        Calendar newCalendar = Calendar.getInstance();
        // 明天
        Calendar tomorrowCalendar = Calendar.getInstance();
        tomorrowCalendar.add(Calendar.DATE, 1);
        // 后天
        Calendar afterTomorrowCalendar = Calendar.getInstance();
        afterTomorrowCalendar.add(Calendar.DATE, 2);
        // 三天后
        Calendar threeDaysFromNowWeekCalendar = Calendar.getInstance();
        threeDaysFromNowWeekCalendar.add(Calendar.DATE, 3);

        ActivityDayVo todayActivityDayVo = ActivityUtil.calendarToActivityDayVo(newCalendar);
        ActivityDayVo tomorrowActivityDayVo = ActivityUtil.calendarToActivityDayVo(tomorrowCalendar);
        ActivityDayVo afterTomorrowActivityDayVo = ActivityUtil.calendarToActivityDayVo(afterTomorrowCalendar);
        String threeDaysFromNowWeek = ActivityUtil.CalendarToWeekStr(threeDaysFromNowWeekCalendar);
        return ActivityDateVO.builder()
                .today(todayActivityDayVo)
                .tomorrow(tomorrowActivityDayVo)
                .afterTomorrow(afterTomorrowActivityDayVo)
                .threeDaysFromNowWeek(threeDaysFromNowWeek)
                .build();
    }

}
